package com.yinxin.thread.state;

/**
 * @author yinxin
 * @Title:
 * @Package
 * @Description:
 * @date 2022/1/714:48
 */
public class Sleep implements Runnable{

    private int ticketNums = 10;

    @Override
    public void run() {
        while (true){
            if(ticketNums<=0){
                break;
            }
            try {
                Thread.sleep(100);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(Thread.currentThread().getName()+"-->拿到了第"+ticketNums--+"张票");
        }
    }

    public static void main(String[] args) {

        Sleep sleep = new Sleep();
        Thread thread1 = new Thread(sleep);
        thread1.start();
    }
}
